package com.uinnova.product.eam.init.schedule;//package com.uinnova.product.eam.init.schedule;

import com.binary.framework.bean.annotation.Comment;
import com.uinnova.product.eam.init.schedule.job.CmdbDataSyncJob;
import com.uinnova.product.eam.init.schedule.job.IAMUserSyncJob;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Comment("IAM用户数据同步定时任务配置")
@Configuration
public class IAMUserDataSyncConfiguration {

    @Value("${guotou.iamuser.data.sync.cron:0 0 1 * * ?}")
    private String iamUserDataSyncCron;

    @Bean
    public JobDetail statisticJob() {
        return JobBuilder.newJob(IAMUserSyncJob.class).withIdentity("IAMUserSyncJob").storeDurably().build();
    }

    @Bean
    public Trigger statisticJobTrigger(JobDetail statisticJob) {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(iamUserDataSyncCron);
        return TriggerBuilder.newTrigger().forJob(statisticJob)
                .withIdentity("IAMUserSyncJob").withSchedule(scheduleBuilder).build();
    }

}
